<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <!--<s:head/>-->
    <title>商品信息</title>
    <jsp:include page="component/head.jsp"/>
	
	<!--CXX：-->
	<script type="text/javascript">
		function getRequestParameter(name) {
		    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		    var r = decodeURI(window.location.search).substr(1).match(reg);
		    if (r != null) return unescape(r[2]); return null;
	    }
	    window.onload = function(){
    		document.getElementsByTagName("h3")[0].innerHTML = getRequestParameter("cname");
		};
		$(document).ready(function () {
			var cid = getRequestParameter("cid");
			var url = "getgoodsbycategory.action?category.cid="+cid;
			$.getJSON(url,function(goods) {
				$.each(goods, function(i, good){
				var singlep = "p_singleproduct.action?gid="+good.gid;
					var inner = '<div class="col-md-3 special-products-grid text-center">'+
								'<a class="brand-name" href="#"><img src="" title="" /></a>'+
								'<a class="product-here" href="#"><img style="width:212px;height:213px;" src="${pageContext.request.contextPath}/upload/'+good.gimage+'" title="product-name" /></a>'+
								'<h4><a href="#">'+good.gname+'</a></h4>'+
								'<a class="product-btn" href="'+singlep+'"><span>'+good.gprice+'元</span><small>购买</small><label> </label></a>';
							    '</div>';
					$("#goods").append(inner);
				}); 
			});
			
		});	
	</script>
	
  </head>
  
  <body>
		<jsp:include page="component/navigator.jsp"/>
			<!----start-slider-script---->
			<script src="${pageContext.request.contextPath}/js/responsiveslides.min.js"></script>
			 <script>
			    // You can also use "$(window).load(function() {"
			    $(function () {
			      // Slideshow 4
			      $("#slider4").responsiveSlides({
			        auto: true,
			        pager: true,
			        nav: true,
			        speed: 500,
			        namespace: "callbacks",
			        before: function () {
			          $('.events').append("<li>before event fired.</li>");
			        },
			        after: function () {
			          $('.events').append("<li>after event fired.</li>");
			        }
			      });
			
			    });
			  </script>
			<!----//End-slider-script---->
			<!-- Slideshow 4 -->
			    <div class="clearfix"> </div>
			<!----- //End-slider---->
			<!----content---->
				<!---top-row--->
                <!--<div class="copyrights">Collect from <a href="http://www.cssmoban.com/"  title="网站模板">网站模板</a></div>-->
				<div class="container"> 
				<!----speical-products---->
				<div class="special-products">
					<div class="s-products-head">
						<div class="s-products-head-left">
							<h3 id = "categoryName"></h3>
						</div>
						<div class="s-products-head-right">
							<a href="#"><span> </span></a>
						</div>
						<div class="clearfix"> </div>
					</div>
					<!----special-products-grids---->
					<div class="special-products-grids">
						<div id="goods">
							
						</div>
						
						</div>
						<div class="clearfix"> </div>
					</div>
					<!---//special-products-grids---->
				</div>
				<!---//speical-products---->
				</div>
			<!----content---->
			<jsp:include page="component/footer.jsp"/>
		</div>
		<!----container---->
	
</body>
</html>
